# !/usr/bin/python3
# -*- coding: utf-8 -*-

import configparser
import json
import logging
import chardet
from os import _exit

__author__ = "Ennis"


try:
    # 配置文件解析
    config = configparser.ConfigParser()
    with open('common/settings.ini', 'rb') as f:
        content = f.read()
        enc = chardet.detect(content)["encoding"]
    config.read('common/settings.ini', encoding=enc)

    log_level = int(config.get('default', 'LOG_LEVEL'))

    HTTP_PORT = int(config.get('default', 'HTTP_PORT'))

    is_debug_str = config.get('default', 'is_debug')
    if is_debug_str.upper() == 'True'.upper():
        is_debug = True
    else:
        is_debug = False

    THREAD_POOL_NUM = int(config.get('default', 'THREAD_POOL_NUM'))
    HTTP_ASYNC_POOL = int(config.get('default', 'HTTP_ASYNC_POOL'))

except Exception as err_info:
    logging.error('parse config fail, error = {}'.format(err_info))
    _exit(0)
